package com.kushuigu.day6.controller;

import com.kushuigu.day6.domain.Enterprise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/books")
public class BookController {

    private final Environment environment;
    private final Enterprise enterprise;

    @Autowired
    public BookController(Environment environment, Enterprise enterprise) {
        this.environment = environment;
        this.enterprise = enterprise;
    }

    @GetMapping("/{id}")
    public String getById(@PathVariable Integer id) {
        System.out.println(environment.getProperty("lesson"));
        System.out.println(enterprise.toString());
        System.out.println("id ==>" + id);
        return "hello, Spring boot";
    }
}
